package com.yoomiito.app.widget.state;

import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yoomiito.app.R;
import com.yoomiito.app.utils.DensityUtil;
import com.yoomiito.app.utils.L;


/**
 *
 */

public class EmptyType_3 extends LayoutType {

    private int layoutId;
    private String emptyContent;
    private int mHeight = -3;
    private TextView emptyTv;
    private OnShowViewListener mShowViewListener;

    public EmptyType_3() {
        this.layoutId = R.layout.layout_empty_4;
    }

    public EmptyType_3(int layoutId) {
        this.layoutId = layoutId;
    }

    @Override
    public int layoutId() {
        return layoutId;
    }

    @Override
    public void show(View emptyView) {
        L.i("EV: " + emptyView);
        emptyTv = emptyView.findViewById(R.id.emptyTv);
        if (emptyTv == null)
            emptyTv = (TextView) emptyView;
        L.i("EV: " + emptyTv);
        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) emptyTv.getLayoutParams();
        if (mHeight != -3) lp.height = mHeight;

        if (!TextUtils.isEmpty(emptyContent)) {
            emptyTv.setText(emptyContent);
        }
        if (mShowViewListener != null) {
            mShowViewListener.showView(emptyTv);
        }
    }

    @Override
    public void hide() {

    }

    public EmptyType_3 setmHeight(int mHeight) {
        this.mHeight = mHeight;
        return this;
    }

    public EmptyType_3 setEmptyContent(String emptyContent) {
        this.emptyContent = emptyContent;
        if (emptyTv != null) {
            emptyTv.setText(emptyContent);
        }
        return this;
    }

    public EmptyType_3 setShowViewListener(OnShowViewListener showViewListener) {
        mShowViewListener = showViewListener;
        return this;
    }

    public interface OnShowViewListener {
        void showView(View view);
    }
}
